import i18n from "@/lang";
import moment from "moment";
import Vue from "vue";
export const developColumn = [
  {
    title: i18n.t('campaignName'),
    dataIndex: 'name',
    scopedSlots: {customRender: 'task'},
    width: 330
  },
  {
    title: '任务状态',
    width: 90,
    key: 'status',
    scopedSlots: {customRender: 'status'}
  },
  {
    title: i18n.t('任务类型'),
    width: 90,
    key: 'upgradeType',
    // scopedSlots: { customRender: 'upgradeVehicle' }
    customRender(text, record) {
      switch (record.type) {
        case 8:
          return '自动升级';
        case 9:
        case 10:
          return '用户升级';
        default:
          return '错误类型';
      }
    }
  },
  {
    title: i18n.t('升级方式'),
    width: 90,
    key: 'upgradeConfig',
    customRender(text, record) {
      switch (record.type) {
        case 8:
          return record.silenceUpgrade ? '静默' : '非静默';
        case 9:
        case 10:
          return record.forceUpgrade ? '强制' : '非强制';
        default:
          return '错误类型';
      }
    }
  },
  {
    title: i18n.t('诊断选项'),
    width: 90,
    key: 'diagnoseFilter',
    customRender(text, record) {
     if(record.diagnoseFilter){
      return '任务ECU'
     }else{
      return '车型ECU'
     }
    }
  },
  {
    title: i18n.t('烧写方式'),
    width: 90,
    key: 'sxfs',
    customRender(text, record) {
      if (record.isEqualUpgrade) {
        return '平刷';
      }
      if (record.freeBurning === 1) {
        return '自由烧写';
      }
      if (record.type === 10) {
        return '循环升级';
      }
      return '正常升级';
    }
  },
  {
    title: i18n.t('sjcl'),
    width: 220,
    key: 'sjcl',
    dataIndex: 'strategyName',
    scopedSlots: {customRender: 'strategyName'}
  },
  {
    title: i18n.t('车型'),
    width: 120,
    key: 'modelName',
    dataIndex: 'modelName',
    scopedSlots: {customRender: 'modelName'}
  },
  {
    title: i18n.t('smartDrivingDomainVersion'),
    width: 150,
    key: 'vehicleVersion',
    dataIndex: 'vehicleVersion',
    scopedSlots: {customRender: 'vehicleVersion'}
  },
  {
    title: i18n.t('expirationDate'),
    width: 180,
    key: 'expirationDate',
    scopedSlots: {customRender: 'expirationDate'}

  },
  {
    title: i18n.t('upgradeVehicle'),
    width: 140,
    key: 'upgradeVehicle',
    scopedSlots: {customRender: 'upgradeVehicle'}
  },
  {
    title: i18n.t('activationTime'),
    width: 120,
    key: 'startTime',
    customRender(text, record) {
      return  moment(record.startTime).format('YYYY-MM-DD');
    },
    sorter: true
  },
  {
    title: i18n.t('创建时间'),
    width: 180,
    key: 'createTime',
    customRender(text, record) {
      return  moment(record.createTime).format('YYYY-MM-DD HH:mm:ss');
    },
    sorter: true
  },
  {
    title: i18n.t('创建人'),
    width: 200,
    key: 'createBy',
    dataIndex: 'createBy'
  },
  {
    title: i18n.t('operation'),
    width: 270,
    fixed: 'right',
    key: 'operation',
    scopedSlots: { customRender: 'operation' }
  }
];

export const channelColumn = [
  {
    title: i18n.t('campaignName'),
    dataIndex: 'name',
    scopedSlots: {customRender: 'task'},
    width: 330
  },
  {
    title: '任务状态',
    width: 90,
    key: 'status',
    scopedSlots: {customRender: 'status'}
  },
  {
    title: i18n.t('任务类型'),
    width: 90,
    key: 'upgradeType',
    // scopedSlots: { customRender: 'upgradeVehicle' }
    customRender(text, record) {
      switch (record.type) {
        case 2:
        case 8:
          return '自动升级';
        case 9:
        case 10:
          return '用户升级';
        default:
          return '错误类型';
      }
    }
  },
  {
    title: i18n.t('升级方式'),
    width: 90,
    key: 'upgradeConfig',
    customRender(text, record) {
      switch (record.type) {
        case 2:
        case 8:
          return record.silenceUpgrade ? '静默' : '非静默';
        case 9:
        case 10:
          return record.forceUpgrade ? '强制' : '非强制';
        default:
          return '错误类型';
      }
    }
  },
  {
    title: i18n.t('sjcl'),
    width: 220,
    key: 'sjcl',
    dataIndex: 'strategyName',
    scopedSlots: {customRender: 'strategyName'}
  },
  {
    title: i18n.t('车型'),
    width: 120,
    key: 'modelName',
    dataIndex: 'modelName',
    scopedSlots: {customRender: 'modelName'}
  },
  {
    title: i18n.t('smartDrivingDomainVersion'),
    width: 150,
    key: 'vehicleVersion',
    dataIndex: 'vehicleVersion',
    scopedSlots: {customRender: 'vehicleVersion'}
  },
  {
    title: i18n.t('expirationDate'),
    width: 180,
    key: 'expirationDate',
    scopedSlots: {customRender: 'expirationDate'}

  },
  {
    title: i18n.t('upgradeVehicle'),
    width: 140,
    key: 'upgradeVehicle',
    scopedSlots: {customRender: 'upgradeVehicle'}
  },
  {
    title: i18n.t('activationTime'),
    width: 120,
    key: 'startTime',
    customRender(text, record) {
      return  moment(record.startTime).format('YYYY-MM-DD');
    },
    sorter: true
  },
  {
    title: i18n.t('创建时间'),
    width: 180,
    key: 'createTime',
    customRender(text, record) {
      return  moment(record.createTime).format('YYYY-MM-DD HH:mm:ss');
    },
    sorter: true
  },
  {
    title: i18n.t('创建人'),
    width: 200,
    key: 'createBy',
    dataIndex: 'createBy'
  },
  {
    title: i18n.t('operation'),
    width: 260,
    fixed: 'right',
    key: 'operation',
    scopedSlots: { customRender: 'operation' }
  }
];
// 循环测试任务列表
export const LoopTestTaskListColumns = [
  {
    title: i18n.t('任务名称'),
    dataIndex: 'name',
    scopedSlots: { customRender: 'taskName' },
    width: 300
  },
  {
    title: i18n.t('任务状态'),
    dataIndex: 'status',
    scopedSlots: { customRender: 'status' },
    width: 140
  },
  {
    title: i18n.t('任务循环次数'),
    dataIndex: 'loopCount',
    scopedSlots: { customRender: 'loopCount' },
    width: 140
  },
  {
    title: i18n.t('有效期'),
    scopedSlots: { customRender: 'effectiveTime' },
    customRender: (text, record, index) => {
      return (record.startTime ? moment(record.startTime).format('YYYY-MM-DD HH:mm:ss') : '-') + '~' + (record.endTime ? moment(record.endTime).format('YYYY-MM-DD HH:mm:ss') : '-')
    },
    width: 340
  },
  {
    title: i18n.t('结束时间'),
    dataIndex: 'actualEndTime',
    scopedSlots: { customRender: 'actualEndTime' },
    customRender: (text, record, index) => {
      return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '-'
    },
    width: 200
  },
  {
    title: i18n.t('生效时间'),
    dataIndex: 'actualStartTime',
    scopedSlots: { customRender: 'actualStartTime' },
    customRender: (text, record, index) => {
      return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '-'
    },
    width: 200
  },
  {
    title: i18n.t('升级类型'),
    dataIndex: 'type',
    scopedSlots: { customRender: 'type' },
    customRender(text, record) {
      if (text === 'USER') {
        return '用户升级' + '/' + (record.forceUpgrade ? '强制升级' : '非强制升级')
      } else if (text === 'AUTO') {
        return '自动升级' + '/' + (record.silenceUpgrade ? '静默升级' : '非静默升级')
      }
    },
    width: 220
  },
  {
    title: i18n.t('品牌'),
    dataIndex: 'company',
    scopedSlots: { customRender: 'company' },
    width: 140
  },
  {
    title: i18n.t('车型'),
    scopedSlots: { customRender: 'modelName' },
    width: 140
  },
  {
    title: i18n.t('车型代码'),
    scopedSlots: { customRender: 'modelCode' },
    width: 140
  },
  {
    title: i18n.t('创建人'),
    dataIndex: 'createBy',
    scopedSlots: { customRender: 'createBy' },
    width: 140
  },
  {
    title: i18n.t('创建时间'),
    dataIndex: 'createTime',
    scopedSlots: { customRender: 'createTime' },
    customRender: (text, record, index) => {
      return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '-'
    },
    width: 200,
    sorter: true
  },
  {
    title: i18n.t('operation'),
    dataIndex: 'operation',
    fixed: 'right',
    scopedSlots: { customRender: 'operation' },
    width: 175
  }
]
// 循环测试任务车辆配置列表
export const VehicleConfigListColumns = [
  {
    title: i18n.t('VIN'),
    dataIndex: 'vin',
    scopedSlots: { customRender: 'vin' },
    width: 260
  },
  {
    title: i18n.t('usage'),
    dataIndex: 'taskOccupied',
    scopedSlots: { customRender: 'usage' },
    width: 100
  },
  {
    title: i18n.t('品牌'),
    dataIndex: 'company',
    scopedSlots: { customRender: 'company' },
    customRender: (text, record, index) => {
      return Vue.$store.getters.getDictCodeObj('companyDictCode')[text] || text;
    },
    width: 140
  },
  {
    title: i18n.t('车系名称'),
    dataIndex: 'brandName',
    scopedSlots: { customRender: 'brandName' },
    width: 140
  },
  {
    title: i18n.t('车型代码'),
    dataIndex: 'modelCode',
    scopedSlots: { customRender: 'modelCode' },
    width: 140
  },
  {
    title: i18n.t('款型名称'),
    dataIndex: 'modelStyleName',
    scopedSlots: { customRender: 'modelStyleName' },
    width: 140
  },
  {
    title: i18n.t('车辆类型'),
    dataIndex: 'vehicleType',
    scopedSlots: { customRender: 'vehicleType' },
    customRender: (text, record, index) => {
      return i18n.t(Vue.$store.state.vehicle.types.find(item => item.id == text).name);
    },
    width: 140
  },
  {
    title: i18n.t('ECU版本'),
    scopedSlots: { customRender: 'ecuVersion' },
    width: 140
  }
]
// 循环测试任务ECU版本配置列表
export const LoopTestTaskEcuVersionConfigColumns = [
  // {
  //   slots: { title: 'addEcuConfigTitle' },
  //   width:40,
  //   scopedSlots: { customRender: 'addEcuConfigCol' }
  // },
  // {
  //   title: '路线序号',
  //   dataIndex: 'serialNo',
  //   width:80,
  //   key: 'serialNo',
  //   customRender:(text,record,index)=>`${index+1}`
  // },
  {
    title: i18n.t('智驾域版本'),
    dataIndex: 'smartDrivingDomainVersion',
    scopedSlots: { customRender: 'smartDrivingDomainVersion' },
    width: 180
  },
  // {
  //   title: i18n.t('源版本'),
  //   dataIndex: 'resourceVersion',
  //   scopedSlots: { customRender: 'resourceVersion' },
  //   width: 230
  // },
  {
    title: i18n.t('目标版本'),
    dataIndex: 'targetVersion',
    scopedSlots: {customRender: 'targetVersion'},
    width: 400,
    special: true
  },
  {
    title: i18n.t('ecuName'),
    dataIndex: 'name',
    width: 140
  },
  {
    title: i18n.t('ECU  ID'),
    dataIndex: 'ecuModuleId',
    scopedSlots: { customRender: 'ecuModuleId' },
    width: 240
  },
  {
    title: i18n.t('软件编码'),
    dataIndex: 'softwareCode',
    scopedSlots: { customRender: 'softwareCode' },
    width: 240
  },
]
// 循环测试任务详情车辆升级明细
export const LoopTestTaskVehicleUpgradeDetailsColumns = [
  {
    title: i18n.t('循环序号'),
    dataIndex: 'loopNo',
    scopedSlots: { customRender: 'loopNo' },
    width: 140
  },
  {
    title: i18n.t('路线序号'),
    dataIndex: 'stepNo',
    scopedSlots: { customRender: 'stepNo' },
    width: 140
  },
  {
    title: i18n.t('升级结果'),
    dataIndex: 'upgradeResult',
    scopedSlots: { customRender: 'upgradeResult' },
    width: 140
  },
  {
    title: i18n.t('状态码'),
    dataIndex: 'normalStatus',
    scopedSlots: { customRender: 'normalStatus' },
    width: 140
  },
  {
    title: i18n.t('升级描述'),
    dataIndex: 'upgradeDesc',
    scopedSlots: { customRender: 'upgradeDesc' },
    width: 200
  },
  {
    title: i18n.t('用户告知'),
    dataIndex: 'updateNoteInfo',
    scopedSlots: { customRender: 'updateNoteInfo' },
    width: 200
  },
  {
    title: i18n.t('升级时间'),
    dataIndex: 'normalTime',
    scopedSlots: { customRender: 'normalTime' },
    customRender: (text, record, index) => {
      return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '-'
    },
    width: 200,
    sorter: true
  },
  {
    title: i18n.t('上报时间'),
    dataIndex: 'createTime',
    scopedSlots: { customRender: 'createTime' },
    customRender: (text, record, index) => {
      return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '-'
    },
    width: 200,
    sorter: true
  },
  // {
  //   title: i18n.t('日志类型'),
  //   dataIndex: 'xxx',
  //   scopedSlots: { customRender: 'xxx' },
  //   width: 140
  // },
  // {
  //   title: i18n.t('日志文件名'),
  //   dataIndex: 'xxx',
  //   scopedSlots: { customRender: 'xxx' },
  //   width: 140
  // },
  {
    title: i18n.t('operation'),
    dataIndex: 'operation',
    fixed: 'right',
    scopedSlots: { customRender: 'operation' },
    width: 140
  }
]
// 循环测试任务详情车辆日志列表，暂不开发
export const DownloadLogColumns = [
  {
    title: i18n.t('任务名称'),
    dataIndex: 'xxx',
    scopedSlots: { customRender: 'xxx' },
    width: 140
  },
  {
    title: i18n.t('日志类型'),
    dataIndex: 'xxx',
    scopedSlots: { customRender: 'xxx' },
    width: 140
  },
  {
    title: i18n.t('日志生成时间'),
    dataIndex: 'xxx',
    scopedSlots: { customRender: 'xxx' },
    width: 140
  },
  {
    title: i18n.t('日志文件名'),
    dataIndex: 'xxx',
    scopedSlots: { customRender: 'xxx' },
    width: 140
  },
  {
    title: i18n.t('operation'),
    dataIndex: 'operation',
    fixed: 'right',
    scopedSlots: { customRender: 'operation' },
    width: 220
  }
]

// 循环测试新建查看车辆ecu版本详情
export const EcuVersionDetailCols = [
  {
    title: i18n.t('ECU名称'),
    dataIndex: 'ecuName',
    scopedSlots: { customRender: 'ecuName' },
    width: 160
  },
  {
    title: i18n.t('ECU ID'),
    dataIndex: 'ecuModuleId',
    scopedSlots: { customRender: 'ecuModuleId' },
    width: 240
  },
  {
    title: i18n.t('软件版本'),
    dataIndex: 'version',
    scopedSlots: { customRender: 'version' },
    width: 160
  },
  {
    title: i18n.t('硬件版本'),
    dataIndex: 'hardVersion',
    scopedSlots: { customRender: 'hardVersion' },
    width: 160
  },
  {
    title: i18n.t('软件编码(车端上报)'),
    dataIndex: 'currentEcuSoftwareCode',
    scopedSlots: { customRender: 'currentEcuSoftwareCode' },
    width: 200
  },
  {
    title: i18n.t('软件编码(云端录入)'),
    dataIndex: 'softwareCode',
    scopedSlots: { customRender: 'softwareCode' },
    width: 200
  },
]

// 成品库列表页面
export const warehouseColumn = [
  {
    title: i18n.t('campaignName'),
    dataIndex: 'name',
    scopedSlots: {customRender: 'task'},
    width: 330
  },
  {
    title: '任务状态',
    width: 90,
    key: 'status',
    scopedSlots: {customRender: 'status'}
  },
  {
    title: i18n.t('车型名称'),
    width: 120,
    key: 'modelName',
    dataIndex: 'modelName',
    scopedSlots: {customRender: 'modelName'}
  },
  {
    title: i18n.t('smartDrivingDomainVersion'),
    width: 150,
    key: 'vehicleVersion',
    dataIndex: 'vehicleVersion',
    scopedSlots: {customRender: 'vehicleVersion'}
  },
  {
    title: i18n.t('sjcl'),
    width: 220,
    key: 'sjcl',
    dataIndex: 'strategyName',
    scopedSlots: {customRender: 'strategyName'}
  },
  {
    title: i18n.t('activationTime'),
    width: 120,
    key: 'startTime',
    customRender(text, record) {
      return  moment(record.startTime).format('YYYY-MM-DD');
    },
    sorter: true
  },
  {
    title: i18n.t('expirationDate'),
    width: 180,
    key: 'expirationDate',
    scopedSlots: {customRender: 'expirationDate'}
  },
  // {
  //   title: i18n.t('升级方式'),
  //   width: 90,
  //   key: 'upgradeConfig',
  //   customRender(text, record) {
  //     switch (record.type) {
  //       case 2:
  //       case 8:
  //         return record.silenceUpgrade ? '静默' : '非静默';
  //       case 9:
  //       case 10:
  //         return record.forceUpgrade ? '强制' : '非强制';
  //       default:
  //         return '错误类型';
  //     }
  //   }
  // },
  {
    title: i18n.t('导入车辆批次'),
    width: 180,
    dataIndex: 'importBatch',
    scopedSlots: {customRender: 'importBatch'}
  },
  {
    title: i18n.t('升级车辆'),
    width: 140,
    key: 'upgradeVehicle',
    scopedSlots: {customRender: 'upgradeVehicle'}
  },
  {
    title: i18n.t('创建时间'),
    width: 180,
    key: 'createTime',
    customRender(text, record) {
      return  moment(record.createTime).format('YYYY-MM-DD HH:mm:ss');
    },
    sorter: true
  },
  {
    title: i18n.t('创建人'),
    width: 200,
    key: 'createBy',
    dataIndex: 'createBy'
  },
  {
    title: i18n.t('operation'),
    width: 260,
    fixed: 'right',
    key: 'operation',
    scopedSlots: { customRender: 'operation' }
  }
];